//
//  UICollectionView+Scale.m
//  Unity-iPhone
//
//  Created by Karl on 2017/3/30.
//
//

#import "UICollectionView+Scale.h"

@implementation UICollectionView (Scale)

- (void)expandItemAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated {
    SelectLayout *layout = (SelectLayout *)self.collectionViewLayout;
    if (animated) {
        //用UIView Animation 包住performBatchUpdates可以使view的Animation代替collectionView默认的动画
        [UIView animateWithDuration:0.6 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:0.3 options:UIViewAnimationOptionCurveEaseInOut animations:^{
            [self performBatchUpdates:^{
                layout.selectedIndexPath = indexPath;
            } completion:^(BOOL finished) {
                
            }];
        } completion:^(BOOL finished) {
            
        }];
        
    } else {
        layout.selectedIndexPath = indexPath;
        [layout invalidateLayout];
    }
}


@end
